const express = require('express');
const router = express.Router();
const channelController = require('../controllers/channelController');
const { authMiddleware } = require('../middleware/auth');

// 获取所有渠道
router.get('/', channelController.getAllChannels);

// 获取单个渠道
router.get('/:id', channelController.getChannelById);

// 创建渠道 - 需要认证
router.post('/', authMiddleware, channelController.createChannel);

// 更新渠道 - 需要认证
router.put('/:id', authMiddleware, channelController.updateChannel);

// 删除渠道 - 需要认证
router.delete('/:id', authMiddleware, channelController.deleteChannel);

// 更新渠道排序 - 需要认证
router.post('/sort', authMiddleware, channelController.updateChannelSort);

// 获取渠道商品价格
router.get('/:channelId/prices', channelController.getChannelPrices);

// 设置渠道商品价格 - 需要认证
router.post('/:channelId/prices', authMiddleware, channelController.setChannelPrice);

// 批量设置渠道商品价格 - 需要认证
router.post('/:channelId/batch-prices', authMiddleware, channelController.batchSetChannelPrices);

router.use(authMiddleware);

module.exports = router; 